
package edu.tongji.jiaowu.service.impl;
 
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.tongji.quickCRUDQ.service.impl.BaseManagerImpl;
import edu.tongji.jiaowu.dao.ScoreDao;
import edu.tongji.jiaowu.service.ScoreManager;
import com.tongji.quickCRUDQ.model.CommonBean;

public class ScoreManagerImpl extends BaseManagerImpl implements ScoreManager {
        private ScoreDao scoreDao;

	
	public CommonBean createScore(){
                return scoreDao.createScore();		
	}
	
/*
	public CommonBean findScores(String refid) {
                return scoreDao.findScores(refid);
       }
*/
	
	public Map queryStudentScore(String studentNo){
		Map scoreInfo=new HashMap();
		BigDecimal gradePoint=scoreDao.findGradePoint(studentNo);
		BigDecimal sumCredit=scoreDao.findSumCredit(studentNo);
		BigDecimal sumPassedCredit=scoreDao.findPassedCredit(studentNo);
		int failedCourseCount=scoreDao.findFailedCourseCount(studentNo);
		scoreInfo.put("gradePoint", gradePoint);
		scoreInfo.put("sumCredit", sumCredit);
		scoreInfo.put("sumPassedCredit", sumPassedCredit);
		scoreInfo.put("failedCourseCount", failedCourseCount);
		List semesters=scoreDao.findStudentScoreSemester(studentNo);
		scoreInfo.put("semesters", semesters);
		int s1=semesters.size();
		for (int i = 0; i < s1; i++) {
			Map semester=(Map) semesters.get(i);
			String schoolYear=(String) semester.get("SCHOOL_YEAR");
			String schoolSemester=(String) semester.get("SCHOOL_SEMESTER");
			List scores=scoreDao.findStudentScore(studentNo, schoolYear, schoolSemester);
			scoreInfo.put(schoolYear+schoolSemester, scores);
		}
		return scoreInfo;
	}

	public void deleteFailElective() {
		scoreDao.deleteFailElective();
	}
	public CommonBean findScoreById(String id){
                return scoreDao.findScoreById(id);
       }	
	public CommonBean findAllScores() {
                return scoreDao.findAllScores();
       }
	public void insertScore(CommonBean scoreBean){
               scoreDao.insertScore(scoreBean);
	}

	public void maskScorePrint(String studentNo) {
		scoreDao.maskScorePrint(studentNo);
	} 	
	public void maskScorePrint(String grade, String majorNo) {
		scoreDao.maskScorePrint(grade,majorNo);
	}	
	public ScoreDao getScoreDao(){
		return scoreDao;
        }	
        
        public void setScoreDao(ScoreDao scoreDao){
                this.scoreDao=scoreDao;	
        }





       		
}

